<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		request.setCharacterEncoding("utf-8");
		String sno = request.getParameter("sno");
		try {
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:mysql://localhost:3306/st?useUnicode=true&characterEncoding=utf-8";
			String user = "root";
			String pass = "123456";
			Connection con = DriverManager.getConnection(url,user,pass);
	    PreparedStatement ps = con.prepareStatement("select * from student2 where sno=?");
		ps.setString(1, sno);
		ResultSet rs = ps.executeQuery();
		rs.next();//rs往下移动指向第一条记录
		String sdep = rs.getString("sdep");
		String ssex = rs.getString("ssex");
		String sage = rs.getString("sage");
		//int sage = rs.getInt("sage");
		String sname = rs.getString("sname");
		rs.close();
		ps.close();
		con.close();
	
	%>	
		<form action="updateinfo.jsp"  method="post">
		   <fieldset>
		      <legend>添加信息</legend>
		      <label>学号:<input type="text" name="sno" value="<%=sno %>" readonly="readonly"></label><br>
		      <label>院系:<select name="sdep">
		       <option value="计算机科学系" <%if(sdep.equals("计算机科学系")) {%> selected="selected"<%} %>>计算机科学系</option>
		      <option value="外语系" <%if(sdep.equals("外语系")){ %>selected="selected"<%} %>>外语系</option>
		      <option value="化工系" <%if(sdep.equals("化工系")){ %> selected="selected"<%} %>>化工系</option>
		      <option value="机械工程系"<%if(sdep.equals("机械工程系")) {%> selected="selected"<%} %>>机械工程系</option>
		      			</select>
		      </label><br>
		      <label>性别:<input type="radio" name="ssex" value="男" <%if(ssex.equals("男")){ %>checked="checked"<%} %>>男
		             <input type="radio" name="ssex" value="女"<%if(ssex.equals("女")){ %> checked="checked" <%} %>>女
		      </label><br>
		      <label>年龄:<input type="text" name="sage" value="<%=sage   %>"></label><br>
		      <label>姓名:<input type="text" name="sname" value="<%=sname %>"></label><br>
		      <label><input type="submit" value="提交"></label>
		   </fieldset>
		</form>
		<%
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		%> 
</body>
</html>